package com.homework.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.homework.content.BaseContext;
import com.homework.entity.Student;
import com.homework.entity.StudentTeacher;
import com.homework.mapper.StudentMapper;
import com.homework.service.StudentTeacherService;
import com.homework.mapper.StudentTeacherMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【student_teacher】的数据库操作Service实现
* @createDate 2025-05-21 16:33:39
*/
@Service
public class StudentTeacherServiceImpl extends ServiceImpl<StudentTeacherMapper, StudentTeacher>
    implements StudentTeacherService{
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public List myStudents(Long userId) {

        return baseMapper.selectList(new LambdaQueryWrapper<StudentTeacher>()
                .eq(StudentTeacher::getTeacherId, userId))
                .stream()
                .map(StudentTeacher::getStudentId)
                .map(studentId -> studentMapper.selectOne(new LambdaQueryWrapper<Student>()
                        .eq(Student::getStudentId, studentId))).toList();
    }
}




